<template>
  <div class="container">
    <div class="centered-div" v-loading="isLoading">居中的div</div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      isLoading: false,
    };
  },
  methods: {
    fetchData() {
      this.isLoading = true;
      // 模拟异步请求数据
      setTimeout(() => {
        // 数据请求完成
        this.isLoading = false;
      }, 3000);
    },
  },
  mounted() {
    this.fetchData();
  },
};
</script>

<style lang="css" scoped>
.container {
  display: flex;
  /*background-color: grey;*/
  justify-content: center;
  align-items: center;
  height: 100vh; /* 使容器的高度为视口高度 */
}
.centered-div {
  width: 200px;
  height: 100px;
  line-height: 100px;
  text-align: center;
  background-color: skyblue;
}
</style>
